package com.ltkj.ticket.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.ticket.domain.dto.TicActivityStockAddDTO;
import com.ltkj.ticket.domain.dto.TicActivityStockQueryDTO;
import com.ltkj.ticket.domain.dto.TicActivityStockUpdateDTO;
import com.ltkj.ticket.domain.vo.TicActivityStockPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicActivityStock;
import com.ltkj.ticket.service.ITicActivityStockService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 活动门票库存Controller
 * 
 * @author ruoyi
 * @date 2023-08-31
 */
@Api(tags = "活动门票库存")
@RestController
@RequestMapping("/actstock")
public class TicActivityStockController extends BaseController
{
    @Autowired
    private ITicActivityStockService ticActivityStockService;


    /**
     * 导出活动门票库存列表
     */
    @ApiOperation("导出活动门票库存列表")
    @RequiresPermissions("ticket:actstock:export")
    @Log(title = "活动门票库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicActivityStock ticActivityStock)
    {
        List<TicActivityStock> list = ticActivityStockService.selectTicActivityStockList(ticActivityStock);
        ExcelUtil<TicActivityStock> util = new ExcelUtil<TicActivityStock>(TicActivityStock.class);
        util.exportExcel(response, list, "活动门票库存数据");
    }

    /**
     * 新增活动门票库存
     */
    @ApiOperation("新增活动门票库存")
    @RequiresPermissions("ticket:actstock:add")
    @Log(title = "活动门票库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicActivityStockAddDTO addDTO)
    {
        return toAjax(ticActivityStockService.insertTicActivityStockNew(addDTO));
    }

    /**
     * 删除活动门票库存
     */
    @ApiOperation("删除活动门票库存")
    @RequiresPermissions("ticket:actstock:remove")
    @Log(title = "活动门票库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityStockIds}")
    public AjaxResult remove(@PathVariable Long[] activityStockIds)
    {
        return toAjax(ticActivityStockService.deleteTicActivityStockByActivityStockIds(activityStockIds));
    }

    /**
     * 修改活动门票库存
     */
    @ApiOperation("修改活动门票库存")
    @RequiresPermissions("ticket:actstock:edit")
    @Log(title = "活动门票库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicActivityStockUpdateDTO updateDTO)
    {
        return toAjax(ticActivityStockService.updateTicActivityStockNew(updateDTO));
    }

    /**
     * 获取活动门票库存详细信息
     */
    @ApiOperation("获取活动门票库存详细信息")
    @RequiresPermissions("ticket:actstock:query")
    @GetMapping(value = "/{activityStockId}")
    public AjaxResult getInfo(@PathVariable("activityStockId") Long activityStockId)
    {
        return success(ticActivityStockService.selectTicActivityStockByActivityStockIdNew(activityStockId));
    }

    /**
     * 查询活动门票库存列表
     */
    @ApiOperation("查询活动门票库存列表")
    @RequiresPermissions("ticket:actstock:list")
    @GetMapping("/list")
    public TableDataInfo list(TicActivityStockQueryDTO queryDTO)
    {
        startPage();
        List<TicActivityStockPageVo> list = ticActivityStockService.selectTicActivityStockListNew(queryDTO);
        return getDataTable(list);
    }
}
